﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using EcSalseManage.App_Code;
using System.IO;
using System.Net;

namespace EcSalseManage.EcSalse
{
    public partial class TestWebForm : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //DataAccess.Operate.DA_Project_Inherit Project_Inherit = new DataAccess.Operate.DA_Project_Inherit();
            //DataEntity.T_Project Project = new DataEntity.T_Project();
            //Project.Project_NO = Project_Inherit.genProjectNO();
            //Project.ProjectNOIdx = Project_Inherit.genProjectIndex().ToString();
            //string filename = "tc";
            //Response.Clear();
            //Response.Buffer = false;
            //Response.ContentType = "application/octet-stream";
            //Response.AppendHeader("content-disposition", "attachment;filename=" + filename + ".txt;");
            //// 读取数据库，循环
          
            //for (int i = 0; i < 300; i++)
            //{
            //    Guid gid = Guid.NewGuid();
            //    Response.Write(gid.ToString()+"\r\n");
            //}
            //Response.Flush();
            //Response.End();
            Response.Write("<h1>这是挨踢实验室</h1>");
        }

        //protected void Button2_Click(object sender, EventArgs e)
        //{

        //    #region 上传附件部分

        //    try
        //    {
        //        DataAccess.Operate.DA_Report_Attach_Operate Report_Attach_Operate = new DataAccess.Operate.DA_Report_Attach_Operate();
        //        //string strFiles = this.HiddenField2.Value.Substring(0, this.HiddenField2.Value.Length - 1);
        //        //string delimStr = "|";
        //        //char[] delimiter = delimStr.ToCharArray();
        //        //string[] split = strFiles.Split(delimiter, 4);
        //        //for (int i = 0; i < split.Length; i++)
        //        //{
        //        DataEntity.T_Report_Attach Report_Attach = new DataEntity.T_Report_Attach();
        //        Report_Attach.Project_Report_MainID = new Guid("C1844839-F1E3-419B-ABAD-6D30FAADF0F2");
        //        //delimStr = ",";
        //        //delimiter = delimStr.ToCharArray();
        //        //string[] item = split[i].ToString().Split(delimiter, 3);
        //        string sFileName = "";
        //        string sFilePath = "";
        //        string sFileType = "";
        //        if (!Directory.Exists("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString()))
        //        {
        //            Directory.CreateDirectory("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString());
        //        }
        //        if (!Directory.Exists("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString() + "\\" + "C1844839-F1E3-419B-ABAD-6D30FAADF0F2"))
        //        {
        //            Directory.CreateDirectory("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString() + "\\" + "C1844839-F1E3-419B-ABAD-6D30FAADF0F2");
        //        }
        //        int fileType = 1;
        //        sFileType = ".jpg";
        //        sFileName = "C1844839-F1E3-419B-ABAD-6D30FAADF0F2" + DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + sFileType;
        //        sFilePath = "\\ReportManager\\" + DateTime.Now.Year + "\\" + "C1844839-F1E3-419B-ABAD-6D30FAADF0F2" + "\\" + sFileName;
        //        string uriString = "\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString() + "\\" + "C1844839-F1E3-419B-ABAD-6D30FAADF0F2" + "\\" + sFileName;
        //        this.txtFilePath.Value = @"C:\Users\tianchao.CENTALINE\Pictures\1_vrhero.jpg";
               
        //        //UpLoadFile(@"C:\Users\tianchao.CENTALINE\Pictures\1_vrhero.jpg", uriString);
        //        this.txtFilePath.PostedFile.SaveAs("\\\\gzs-ecc02\\ReportManager\\" + DateTime.Now.Year.ToString() + "\\" + "C1844839-F1E3-419B-ABAD-6D30FAADF0F2" + "\\" + sFileName);

        //        //Report_Attach.Project_Report_FileID = Convert.ToInt32(item[0]);
        //        //Report_Attach.Project_Report_ExchangeTypeID = 11;
        //        //Report_Attach.Project_Report_FilePath = sFilePath;
        //        //Report_Attach.Project_Report_FileDesc = item[2];
        //        //Report_Attach.Project_Report_FileName = sFileName;
        //        //Report_Attach_Operate.Insert(Report_Attach);

        //        //DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 5, "C1844839-F1E3-419B-ABAD-6D30FAADF0F2", 4);
        //        //}
        //    #endregion
        //    }
        //    catch (Exception ex)
        //    {
        //        Response.Write("<script>alert('" + ex.Message + "');</script>");
        //    }
        //    finally
        //    {
        //        Response.Write("<script>alert('ok');</script>");
        //    }

        //}


        #region WebClient上传附件
        /// <summary>
        /// WebClient上传文件至服务器
        /// </summary>
        /// <param name="fileNamePath">文件名，全路径格式</param>
        /// <param name="uriString">服务器文件夹路径</param>
        public void UpLoadFile(string fileNamePath, string uriString)
        {

            try
            {
                /**/
                /// 创建WebClient实例 
                WebClient myWebClient = new WebClient();
                myWebClient.Credentials = CredentialCache.DefaultCredentials;
                // 要上传的文件 
                FileStream fs = new FileStream(fileNamePath, FileMode.Open, FileAccess.Read);
                // FileStream fs = OpenFile(); 
                BinaryReader r = new BinaryReader(fs);
                byte[] postArray = r.ReadBytes((int)fs.Length);
                Stream postStream = myWebClient.OpenWrite(uriString, " PUT ");
                try
                {

                    // 使用UploadFile方法可以用下面的格式
                    // myWebClient.UploadFile(uriString,"PUT",fileNamePath); 


                    if (postStream.CanWrite)
                    {
                        postStream.Write(postArray, 0, postArray.Length);
                        postStream.Close();
                        fs.Dispose();
                    }
                    else
                    {
                        postStream.Close();
                        fs.Dispose();

                    }
                }
                catch (Exception err)
                {
                    postStream.Close();
                    fs.Dispose();
                    // Utility.LogWriter log = new Utility.LogWriter(); 
                    throw err;
                }
                finally
                {
                    postStream.Close();
                    fs.Dispose();
                }
            }
            catch (Exception ex)
            {
                Response.Write("<script>alert('" + ex.Message + "');</script>");
            }
        }
        #endregion

        protected void Button4_Click(object sender, EventArgs e)
        {
            if (RadioButtonList1.SelectedValue == "")
            { 
                
            }
        }

        protected void Button6_Click(object sender, EventArgs e)
        {
            //DataAccess.Operate.DA_Project_Referral_Operate Project_Referral_Operate = new DataAccess.Operate.DA_Project_Referral_Operate();
            //DataEntity.T_Project_Referral Project_Referral = new DataEntity.T_Project_Referral();
            //Project_Referral.Project_Referral_ID = Guid.NewGuid();
            //Project_Referral.Project_Referral_MainID = Guid.NewGuid();
            //Project_Referral.Project_Referral_Tally = 123;
            //Project_Referral.Project_Referral_Type = 1;
            //Project_Referral_Operate.Insert(Project_Referral);

            //DataAccess.Operate.DA_Project_OutComm_Operate Project_OutComm_Operate = new DataAccess.Operate.DA_Project_OutComm_Operate();
            //DataEntity.T_Project_OutComm Project_OutComm = new DataEntity.T_Project_OutComm();
            //Project_OutComm.Project_OutComm_ID = Guid.NewGuid();
            //Project_OutComm.Project_OutComm_MainID = Guid.NewGuid();
            //Project_OutComm.Project_OutComm_Tally = Convert.ToDecimal(0.04);
            //Project_OutComm.Project_OutComm_Type = 3;
            //Project_OutComm_Operate.Insert(Project_OutComm);


            DataAccess.Operate.DA_Project_CommissionConditions_Operate Project_CommissionConditions_Operate = new DataAccess.Operate.DA_Project_CommissionConditions_Operate();
            //DataEntity.T_Project_CommissionConditions Project_CommissionConditions = new DataEntity.T_Project_CommissionConditions();
            //Project_CommissionConditions.Project_CommissionConditions_DayNumber = 1;
            //Project_CommissionConditions.Project_CommissionConditions_DayType = 2;
            //Project_CommissionConditions.Project_CommissionConditions_ID = Guid.NewGuid();
            //Project_CommissionConditions.Project_CommissionConditions_MainID = Guid.NewGuid();
            //Project_CommissionConditions.Project_CommissionConditions_Tally =Convert.ToDecimal(12);
            //Project_CommissionConditions.Project_CommissionConditions_Type = 1;
            //Project_CommissionConditions_Operate.Insert(Project_CommissionConditions);
            //Response.Write(Project_OutComm.Project_OutComm_Tally);
            //Project_CommissionConditions_Operate.Delete("566658CB-DC10-42F0-86AE-A7FF25CE6279");

            //DataTable table = Project_CommissionConditions_Operate.SelectAllByMainID("1F55EDA9-C48E-4A65-AC0D-E0F4E8C076AC");
            //if (table.Rows.Count > 0)
            //{
            //    Response.Write(table.Rows[0][1].ToString());
            //}

          //  DataAccess.Operate.DA_Bonuses_Detal_Operate Bonuses_Detal_Operate = new DataAccess.Operate.DA_Bonuses_Detal_Operate();
          //  //DataEntity.T_Bonuses_Detal Bonuses_Detal = new DataEntity.T_Bonuses_Detal();
          //  //Bonuses_Detal.Bonuses_Detal_Award1 = "sdfsdfsdf";
          //  //Bonuses_Detal.Bonuses_Detal_Award2 = "234234234";
          //  //Bonuses_Detal.Bonuses_Detal_ID = Guid.NewGuid();
          //  //Bonuses_Detal.Bonuses_Detal_MainID = Guid.NewGuid();
          //  //Bonuses_Detal_Operate.Insert(Bonuses_Detal);
          //DataEntity.T_Bonuses_Detal Bonuses_Detal =(DataEntity.T_Bonuses_Detal)Bonuses_Detal_Operate.SelectOneByMainID("5F6C5539-70CC-494C-BA0D-CF036C5A0F88");
          //write(Bonuses_Detal.Bonuses_Detal_ID.ToString());

          //  DataAccess.Operate.DA_SalesAgent_Detal_Operate SalesAgent_Detal_Operate = new DataAccess.Operate.DA_SalesAgent_Detal_Operate();
          //DataEntity.T_SalesAgent_Detal SalesAgent_Detal = new DataEntity.T_SalesAgent_Detal();
          ////SalesAgent_Detal.SalesAgent_Detal_Alone = "234234";
          ////SalesAgent_Detal.SalesAgent_Detal_Developer = "dfdsg";
          ////SalesAgent_Detal.SalesAgent_Detal_MainID = Guid.NewGuid();
          ////SalesAgent_Detal.SalesAgent_Detal_ID = Guid.NewGuid();
          ////SalesAgent_Detal_Operate.Update(SalesAgent_Detal);
          //SalesAgent_Detal_Operate.DeleteByMainID("CB9DB499-9EC1-4C01-AA1F-C949E0F968F1");

            //DataAccess.Operate.DA_LeaseAgent_Detal_Operate LeaseAgent_Detal_Operate = new DataAccess.Operate.DA_LeaseAgent_Detal_Operate();
            ////DataEntity.T_LeaseAgent_Detal LeaseAgent_Detal = new DataEntity.T_LeaseAgent_Detal();
            ////LeaseAgent_Detal.LeaseAgent_Detal_Central = "sdfsdf";
            ////LeaseAgent_Detal.LeaseAgent_Detal_Developer = "sdfs2332";
            ////LeaseAgent_Detal.LeaseAgent_Detal_ID = Guid.NewGuid();
            ////LeaseAgent_Detal.LeaseAgent_Detal_MainID = Guid.NewGuid();
            //LeaseAgent_Detal_Operate.DeleteByMainID("075FC84A-5218-4E8E-B09C-D6F18341FE66");

            //DataAccess.Operate.DA_LinkAgent_Detal_Operate LinkAgent_Detal_Operate = new DataAccess.Operate.DA_LinkAgent_Detal_Operate();
            ////DataEntity.T_LinkAgent_Detal LinkAgent_Detal = new DataEntity.T_LinkAgent_Detal();
            ////LinkAgent_Detal.LinkAgent_Detal_Developer = "sdfsdf234";
            ////LinkAgent_Detal.LinkAgent_Detal_Link = "465465324sdfsdf";
            ////LinkAgent_Detal.LinkAgent_Detal_MainID = Guid.NewGuid();
            ////LinkAgent_Detal.LinkAgent_Detal_ID = Guid.NewGuid();
            ////LinkAgent_Detal_Operate.Insert(LinkAgent_Detal);
            //LinkAgent_Detal_Operate.DeleteByMainID("7396A96E-7F72-4C51-A38C-5BC66364645C");

            //DataAccess.Operate.DA_Project_OutComm_Operate Project_OutComm_Operate = new DataAccess.Operate.DA_Project_OutComm_Operate();
            ////DataEntity.T_Project_OutComm Project_OutComm = new DataEntity.T_Project_OutComm();
            ////Project_OutComm.Project_OutComm_ID = Guid.NewGuid();
            ////Project_OutComm.Project_OutComm_MainID = Guid.NewGuid();
            ////Project_OutComm.Project_OutComm_Tally = Convert.ToDecimal(12.1);
            ////Project_OutComm.Project_OutComm_Type = 1;
            ////Project_OutComm_Operate.Insert(Project_OutComm);
            //DataTable table = Project_OutComm_Operate.SelectAllByMainID("1F81F7DE-1B7A-461D-8680-CA3ECF3A42D4");
            //if (table.Rows.Count > 0)
            //{
            //    write(table.Rows[0][0].ToString());
            //}

            DataAccess.Operate.DA_Project_Referral_Operate Project_Referral_Operate = new DataAccess.Operate.DA_Project_Referral_Operate();
            //DataEntity.T_Project_Referral Project_Referral = new DataEntity.T_Project_Referral();
            //Project_Referral.Project_Referral_ID = Guid.NewGuid();
            //Project_Referral.Project_Referral_MainID = Guid.NewGuid();
            //Project_Referral.Project_Referral_Tally = Convert.ToDecimal(1.01);
            //Project_Referral.Project_Referral_Type = 1;
            //Project_Referral_Operate.Insert(Project_Referral);
            Project_Referral_Operate.DeleteByMainID("6D1D1ADA-65D7-44B7-BA0C-CC2AD478513B");
            string str = "1,3,0,1|4,2,1,0.6|";
            str=str.Substring(0,str.Length-1);
            string[] entitys=str.Split('|');
            for (int i = 0; i < entitys.Length; i++)
            { 
                string[] entity=entitys[i].Split(',');
            }
        }

        public void write(string str)
        {
            Response.Write(str);
        }
     
    }
}